<template>
  <div class="znsb-div">
    <div class="header">
      <span class="title">{{dataObject.tagName}}</span>
      <span class="close" @click="emit('close')"></span>
    </div>
    <img
      class="loveImg"
      v-if="!props.info.clused"
      @click="changeClused('1')"
      src="/images/new/tag/love.png"
    />
    <img class="loveImg"  @click="changeClused('0')" v-else src="/images/new/tag/loved.png" />
    <div class="content-info" style="margin-top: 50px">
      <!--道路监控 -->
      <el-tabs v-model="videoTab">
        <el-tab-pane label="实时视频" name="实时视频">
          <div class="video-box">
            <onem ref="videoref" :vid="dataObject.tempDeviceId" />
          </div>
        </el-tab-pane>
      </el-tabs>
      <div class="header-box">
        <span class="header-name">抓拍记录</span>
      </div>
      <div class="table-box" v-if="typeSnap == 'event'">
        <div class="header-t">
          <span class="ht">照片</span>
          <span class="ht">事件标题</span>
          <span class="ht">抓拍时间</span>
          <!-- <span class="ht">处置状态</span> -->
        </div>
        <div class="table-cell-box">
          <div class="cell-p" c v-for="(item, index) in eventList" :key="index">
            <span class="cell">
              <img class="img" :src="item.capturePic" />
            </span>
            <span class="cell" :title="item.desc"> {{item.desc}} </span>
            <span class="cell"> {{ item.captureTime }} </span>
            <!-- <span class="cell"> 进行中 </span> -->
          </div>
        </div>
      </div>
       <div class="table-box" v-if="typeSnap == 'face'">
        <div class="header-t">
          <span class="ht">照片</span>
          <span class="ht">性别</span>
          <span class="ht">抓拍时间</span>
          <span class="ht">状态</span>
        </div>
        <div class="table-cell-box">
          <div class="cell-p" c v-for="(item, index) in eventList" :key="index">
            <span class="cell">
              <img class="img" :src="item.capturePic" />
            </span>
            <span class="cell"> {{item.gender}} </span>
            <span class="cell"> {{ item.captureTime }} </span>
            <span class="cell"> -- </span>
          </div>
        </div>
      </div>
       <div class="table-box" v-if="typeSnap == 'vehicle'">
        <div class="header-t">
          <span class="ht">照片</span>
          <span class="ht">车牌号</span>
          <span class="ht">抓拍时间</span>
          <span class="ht">状态</span>
        </div>
        <div class="table-cell-box">
          <div class="cell-p" c v-for="(item, index) in eventList" :key="index">
            <span class="cell">
              <img class="img" :src="item.capturePic" />
            </span>
            <span class="cell"> {{item.plateNo}} </span>
            <span class="cell"> {{ item.captureTime }} </span>
            <span class="cell"> -- </span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
const emit = defineEmits(["close",'changeClose']);
const props = defineProps({
  info: Object,
  isd: {
    default: false,
    type: Boolean,
  },
});

const changeClused = (clused) => {
  emit('changeClose', clused);
};

let currentTab = ref("2");
const changTab = (tab) => {
  currentTab.value = tab;
};

let videoTab = ref("实时视频");
let videoref = ref();

let contentTab = ref("ryzpjl");

let optionsData = ref();

let lylist = ref([
  { value: "1", label: "来源1" },
  { value: "2", label: "来源2" },
  { value: "3", label: "来源3" },
]);

let ztlist = ref([
  { value: "1", label: "状态1" },
  { value: "2", label: "状态2" },
  { value: "3", label: "状态3" },
]);
let search = ref({
  ly: "",
  zt: "",
});

watch(videoTab, () => {
  if (videoref.value) {
    videoref.value.resize();
  }
});

watch(currentTab, () => {
  if (currentTab.value == "3") {
    optionsData.value = {
      xAxis: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
      in: [120, 132, 101, 134, 90, 230, 210],
      out: [132, 332, 301, 334, 190, 330, 310],
    };
  }
});
let dataObject = ref({});
const getData = () => {
  useApi
    .post("/dynamicview/ar/tagDetail", { tagId: props.info.tagId })
    .then((res) => {
      dataObject.value = res.data.tagInfo;
      // state.pm = res.data.tagInfo
      // state.data1 = res.data.faceStats
      // state.data2 = res.data.vehicleStats
      // state.data3 = res.data.tempCapture
      // if (state.pm.templateId == 'TCC') {
      //   getEvent()
      //   getEvent4()
      // }
      // if (state.pm.templateId == 'CBTKQ') {
      //   getEvent1()
      // }
      // if (state.pm.templateId == 'JYXF') {
      //   getEvent2()
      // }
      // if (state.pm.templateId == 'BGQ') {
      //   getEvent3()
      // }
      // if (state.pm.templateId == 'CBTKQ' || state.pm.templateId == 'JMQ') {
      //   setTimeout(() => {
      //     state.pm.templateId == 'CBTKQ' ? chart3() : chart4()
      //   }, 1000);
      // }
    });
};

// 获取事件
let eventList = ref([]);
let typeSnap = ref("event");
const getEvent = () => {
  if(!dataObject.value.tempDeviceId) return
  useApi
    .post("/dynamicview/ar/getcitymgrlistbydeviceid", {
      deviceId: dataObject.value.tempDeviceId,
    })
    .then((res) => {
      // {
      //   "capturePic": "https://vp.bcdtech.cn:8787/picture?url=http://20.13.9.232:80/picture/Streaming/tracks/303/?name=ch00003_01010003140053933721600013103&size=13103",
      //   "gender": "女",
      //   "captureTime": "2025-03-05 15:25:04"
      // },
      //  {
      //   "capturePic": "https://vp.bcdtech.cn:8787/picture?url=http://20.13.7.221:80/picture/Streaming/tracks/3803/?name=ch00038_00010004650100477081600640316&size=640316",
      //   "plateNo": "津MTX823",
      //   "color": "red",
      //   "type": "vehicle",
      //   "captureTime": "2025-03-05 15:36:19"
      // },
      // if (res.data.faceCaptureList && res.data.faceCaptureList.length > 0) {
      //   eventList.value = res.data.faceCaptureList;
      //   typeSnap.value = "face";
      // } else if (
      //   res.data.vehicleCaptureList &&
      //   res.data.vehicleCaptureList.length > 0
      // ) {
      //   eventList.value = res.data.vehicleCaptureList;
      //   typeSnap.value = "vehicle";
      // }
      //  {
      //   "capturePic": "https://vp.bcdtech.cn:8787/pic?AC01F06B0980F50E45D3*hcs200cdb64493240499_2021/rongliangfugai/1522;174114423606162593217?pic*2067005287*810545*4617*AC01F06B0980F50E45D3-2*1741149876",
      //   "desc": "乱堆物堆料",
      //   "captureTime": "2025-03-05 12:53:38"
      // },
      eventList.value = res.data.citymgrList
    });
};

watch(
  dataObject,
  () => {
    getEvent();
  },
  {
    deep: true,
    immediate: true,
  }
);

watch(
  () => props.info,
  (newval) => {
    if (newval.tagId) {
      getData();
    }
  },
  {
    deep: true,
    immediate: true,
  }
);

onMounted(() => {});
</script>

<style lang="scss">
.znsb-div {
  width: 503px;
  min-height: 520px;
  background: url("/images/new/tag/tagbg.png") no-repeat;
  background-size: 100% 100%;
  position: relative;
  padding-bottom: 30px;
  .loveImg {
    width: 40px;
    height: 40px;
    position: absolute;
    right: 40px;
    top: 75px;
    cursor: pointer;
     z-index: 999;
  }
  .header {
    width: 100%;
    height: 52.5px;
    position: relative;
    background: url("/images/new/tag/header.png") no-repeat;
    background-size: 100% 100%;
    .title {
      display: inline-block;
      height: 100%;
      padding-left: 25px;
      font-family: YouSheBiaoTiHei;
      font-size: 25px;
      color: #ffffff;
      line-height: 60px;
    }

    .close {
      width: 40px;
      height: 40px;
      position: absolute;
      right: 16px;
      top: 20.5px;
      line-height: 40px;
      text-align: center;
      color: #fff;
      font-size: 30px;
      cursor: pointer;
    }
  }
  .tab-content {
    margin: 23px 10px 10px 33px;
    width: 366px;
    height: 40px;
    background: url("/images/new/tag/tabbg.png") no-repeat;
    background-size: 100% 100%;
    display: flex;
    align-items: center;
    padding: 2px 4px;
    position: relative;
    .tab-btn {
      width: 115px;
      height: 100%;
      text-align: center;
      line-height: 36px;
      font-family: YouSheBiaoTiHei;
      font-size: 21px;
      color: #ffffff;
      cursor: pointer;
      &.active {
        background: url("/images/new/tag/tab.png") no-repeat;
        background-size: 100% 100%;
      }
    }
  }

  .content-info {
    padding: 0 30px;
    .table-box {
      width: 100%;
      background: url("/images/new/tag/tablebg.png") no-repeat;
      background-size: 100% 100%;
      .formInfo {
        width: 100%;
        padding: 20px;
        .el-form-item {
          margin-bottom: 0;
        }
        .el-form-item__label {
          font-family: PingFangSC, PingFang SC;
          font-size: 18px;
          color: #ffffff;
        }
        .form-item {
          font-family: PingFangSC, PingFang SC;
          font-size: 18px;
          color: #ffffff;
        }
      }
    }
    .map-box {
      width: 100%;
      height: 248px;
    }
  }
}
</style>

<style lang="scss">
.znsb-div {
  .video-box {
    width: 440px;
    height: 247.5px;
  }
  .el-select__wrapper {
    background: #067cc0;
    span {
      color: #ffffff !important;
    }
  }
  .el-tabs__item {
    font-family: YouSheBiaoTiHei;
    font-size: 21px;
    color: #ffffff;
    line-height: 29px;
    text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
    &.is-active {
    }
  }
  .el-tabs__nav-wrap:after {
    background: none;
  }
  .el-tabs__active-bar {
    background: #18e1ff;
  }
  .header-box {
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .header-name {
      font-family: YouSheBiaoTiHei;
      font-size: 21px;
      color: #ffffff;
    }
  }
  .table-box {
    margin-top: 15px;
    width: 100%;
    background: url("/images/new/tag/tablebg.png") no-repeat;
    background-size: 100% 100%;
    .header-t {
      display: flex;
      align-items: center;
      width: 100%;
      height: 40px;
      background: url("/images/new/tag/headerbg.png") no-repeat;
      background-size: 100% 100%;
      color: #fff;
      .ht {
        height: 100%;
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        font-size: 18px;
        color: #ffffff;
        line-height: 40px;
        margin: 16px 2px;
        &:nth-child(1) {
          padding-left: 20px;
        }
        &:nth-child(1) {
          width: 100px;
        }
        &:nth-child(2) {
          width: 100px;
        }
        &:nth-child(3) {
          flex: 1;
        }
        &:nth-child(4) {
          width: 100px;
        }
      }
    }
    .table-cell-box {
      width: 100%;
      height: 175px;
      overflow: auto;
      .cell-p {
        height: 50px;
        display: flex;
        align-items: center;
        overflow: hidden;
        margin: 8px 0;
        .cell {
          height: 100%;
          font-family: PingFangSC, PingFang SC;
          font-weight: 500;
          font-size: 18px;
          color: #ffffff;
          line-height: 50px;
          margin: 16px 2px;
          word-wrap: break-word; /* 长单词换行 */
          overflow-wrap: break-word; /* 推荐使用 */
          word-break: break-all; /* 强制在任意字符间换行 */
          white-space: normal; /* 默认换行行为 */
          // padding-left:12px;
          &:nth-child(1) {
            width: 100px;
            text-align: center;
            .img {
              width: 85px;
              height: 47.5px;
            }
          }
          &:nth-child(2) {
            width: 100px;
          }
          &:nth-child(3) {
            flex: 1;
            white-space: nowrap; /* 禁止换行 */
            overflow: hidden; /* 隐藏溢出内容 */
            text-overflow: ellipsis; /* 超出用省略号表示 */
          }
          &:nth-child(4) {
            width: 100px;
          }
        }
      }
    }
  }
  .echarts-box {
    height: 215px;
  }
  .info-box {
    padding: 13px;
    font-family: PingFangSC, PingFang SC;
    font-size: 18px;
    color: #ffffff;
    p {
      margin: 0;
      font-family: PingFangSC, PingFang SC;
      font-size: 18px;
      color: #ffffff;
      line-height: 27px;
      display: flex;
      align-items: center;
      .icon {
        border-radius: 50%;
        width: 9px;
        height: 9px;
        background: #88d4ff;
        margin-right: 15px;
      }
    }
  }
}
</style>